define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {

		function get_data_getlist(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"store": [{"store_id": "001","name": "世达","point": 100,"popularity": 100,"sales": 1000,"service": 100,"agenter": 5,"brand": 5,"vote": 10},{"store_id": "002","name": "博士","point": 100,"popularity": 100,"sales": 1000,"service": 100,"agenter": 5,"brand": 5,"vote": 10}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		//投票回复
		function get_data_vote(result){
		    if(false) {
                result = '{"success": true,"msg": "","result": "","session": "7311da98bd0f18eb15a96bcb263f4153"}';
                return JSON.parse(result);
            } else {
                return result;
            }
		}


		//返回信息
		return {
			//行业排名一览
			getlist: function(region_id, cat_type_id, order, nPage,store_type, callback,calldone) {
				Http.post({
					method: 'info.ranking.getlist',
					order:order,
					nPage:nPage,
					pagelimit:8,
					region_id:region_id,
					cat_type_id,cat_type_id,
					store_type:store_type
				},
				function(result) {
					//请求成功
					if(result){
						callback(get_data_getlist(result).result)
					}
				},
				function(e) {
					//请求异常
				},
				function() {
					if(calldone)
                        calldone();
				});
			},
            //投票
			get_vote: function(store_id,callback) {
				Http.post({
					method: 'info.ranking.vote',
					store_id:store_id
				},
				function(result) {
					//请求成功
					if(result){
                   		callback(get_data_vote(result))
                	}
				},
				function(e) {
				//请求异常
				},
				function() {
					//请求完成，一般不做什么事情
				});
			}

		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Industryrankingsdetail", factory);
});